/*
 * DictionaryTermsFile.h
 *
 *  Created on: Oct 12, 2012
 *      Author: m
 */

#ifndef DICTIONARYTERMSFILE_H_
#define DICTIONARYTERMSFILE_H_

#include <memory>
#include "DictionaryTerm.h"
#include "DictionaryTermSerializer.h"
#include "../../physical_layer/FixedSizeRegisterSequentialFile.h"

//#define _DTF_DEFAULT_REGISTER_SIZE _DICTIONARY_TERM_SERIALIZATION_BLOCK_SIZE

using namespace physical;

class DictionaryTermsFile
{
protected:
    std::unique_ptr<DictionaryTermSerializer> m_serializer;
    FixedSizeRegisterSequentialFile m_registersFile;
    static const openmode defaulOpenmode;

public:
    DictionaryTermsFile( size_t readBufferSize, size_t writeBufferSize, bool serializeRandomKey = true );
	DictionaryTermsFile( const char fileName[] = NULL,
	        openmode mode = defaulOpenmode, size_t readBufferSize = 1,
	        size_t writeBufferSize = 1, bool serializeRandomKey = true );
	virtual ~DictionaryTermsFile();

	std::shared_ptr<DictionaryTerm> get();
	void put( DictionaryTerm* newTerm );
	bool hasNext();
	void open( const char filename[], openmode mode  = defaulOpenmode );
	void close();
};

#endif /* DICTIONARYTERMSFILE_H_ */
